home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
LIBRARY
/
FUTILS
/
FBIOS.DOC
next >
Wrap
Text File
|
1989-02-19
|
7KB
|
200 lines
/\ RKCP /\
\/ RKCP \/
********************************************************************
************************* FBIOS by Rex Kerr ************************
************************ Copyright (C) 1989 ************************
********************************************************************
This is a small unit for Turbo Pascal 5.0 written in assembly
language. I wrote it in assembly language for two reasons:
1) I wanted it as fast as I could have it
2) I wanted it as small as I could have it
So I wrote it in assembly language. Programming in assembler,
compared with programming in pascal, is tedious, boring, and
"dangerous." But it has advantages that cannot be overlooked. It
produces tiny code, and is far more flexible that Pascal. I
purposely haven't included any of the "dangerous" BIOS interrupts
(like disk service) because they are too hard to test and debug
(not to mention use!). So here are 16 of the BIOS routines I use
most:
***
BiosPrintScr;
This simply does a PrtSc. Nothing more, nothing less.
***
BiosCurShape(start,stop : byte);
This sets the shape of the cursor. Lines are numbered 0 to 7 on
CGAs and 0 to 13 on monochrome. The normal cursor is 6 and 7 (CGA)
or 12 and 13 (monochrome). You can make the cursor dissapear by
setting start to 32.
***
BiosGetCur(var start,stop : byte);
This gets the shape of the cursor. See BiosCurShape above.
***
BiosGotoxy(x,y : byte);
This positions the cursor just like TP's GotoXY does. But BIOS
always has the full screen as its window. Therefore, I use GotoXY
for window-relative gotos and BiosGotoXy for screen-relative gotos.
***
BiosGetxy(var x,y : byte);
This gets the position of the cursor in screen coordinates. See
BiosGotoxy
***
BiosScroll(lines : shortint; x,y,w,h : byte; attr : byte);
This lets you define a window with X,Y,W,H and scroll it up the
number of lines specified. To scroll down, set a negative number.
Any new lines resulting from scrolling will be blank and in
the text attributes of attr. If you are using the CRT unit in your
program, you can have the new attributes the same as the ones in TP
by putting the CRT variable textattr in for the attr byte.
example: BiosScroll(-2,1,1,80,25,textattr); { Scrolls whole screen
down 2 lines in current
TP text attribute }
***
BiosChar(ch : char; attr : byte);
This writes ch to the screen in attr at the current position of the
cursor. The cursor is NOT updated, and no characters are
interpreted. In other words, bioschar(^G,textattr) would write
ASCII character #7 to the screen, whereas write(^G) would sound a
short beep.
***
BiosGetChar(var ch : char; var attr : byte);
This reads ch and attr from the screen at the current cursor
position. The cursor is not updated; see BiosChar.
***
BiosPutPixel(colr : byte; x,y : word);
This writes a pixel of color colr to the screen at X,Y. You must
be in graphics mode. I do not recommend using this, however! It
is both slower and less portable than the Turbo Graph unit. But,
it IS smaller, so if you are really really tight on space and only
want to draw a few dots or lines (or other simple things), it might
do.
***
BiosGetPixel(x,y : word) : byte;
This function returns the color of the pixel at X,Y. See
BiosPutPixel.
***
BiosEquip : word;
This returns the BIOS's equipment list. Here's how to decode the
word:
Bits in word Use To get them at the beginning of a word
15,14 # of printers w := w shr 14;
12 Game I/O attached w := w and $1000; w := w shr 12;
11,10,9 # of RS-232 w := w and $0E00; w := w shr 9;
7,6 # of disk drives w := (w and $00C0) shr 6; inc(w);
5,4 Initial video mode w := (w and $0030) shr 4;
3,2 Amount of RAM w := (w and $000C) shr 2; inc(w);
w := w shl 4;
0 Any disk drives? w := w and $0001;
If bit 0 = 0 then there are NO disk drives; otherwise the number in
bits 7,6 is right. 3,2 contains the amount of ram on the motherboard
(whatever you want that for) in kbytes. Bits 5,4 contain the
startup video configuration. 1 = 40 by 25 CGA, 2 = 80 by 25 CGA,
and 3 = 80 by 24 monochrome. This is a complex result; for more
information, you can look it up in any good book on advanced
MS-DOS or in the BIOS Technical Reference manual. (By the way,
it is interrupt $11.)
***
BiosReadKey : word;
This is not a duplicate of Turbo's ReadKey. For one thing, you
never have to read twice to get one key. The low byte of the
word is the ASCII code returned, and the high byte is the scan
code returned. There is a table of the scan codes on page 450
of the TP5 Reference guide. Some experimenting on your part may
be necessary to get a better understanding of this function.
***
BiosTestKey(var key : word) : boolean;
If there aren't any keys waiting to be processed, BiosTestKey will
return false and leave key undefined. If there is a key waiting to
be processed, BiosTestKey will return true, and key will be set to
the key waiting. It will not be removed, however; you need to call
BiosReadKey (or ReadKey) for that.
***
BiosShiftStatus : byte;
This function returns the shift status byte of the computer. Here
is the bit map of the byte:
7 : Insert ON 6 : CapsLock ON
5 : NumLock ON 4 : ScrollLock ON
3 : Alt DOWN 2 : Ctrl DOWN
1 : Lft-Shft DOWN 0 : Rgt-Shft DOWN
The byte is at location 0:$417 (in case you want to modify any
of the 7-4 bits);
***
BiosPrintChar(prn_num : byte; ch : char) : byte;
Prn_num is the number of the printer to use (0 to 2 is valid),
and ch is the character to print. It returns a byte contaning
the printer status. Here is a bit map of that byte:
7 : Not busy 6 : Acknowledge
5 : Out of paper 4 : Selected
3 : I/O error 2 : *UNUSED*
1 : *UNUSED* 0 : Time out
I'm not sure what all of the codes mean, but you can always seem
to write to the printer when bits 7 and 4 are on.
***
BiosPrintStatus(prn_num : byte) : byte;
This just returns the status byte of the specified printer
(without printing a character). It is good to call this before
you print to see if you can or not.
***
And that's it. If I've left anything out, or if anything is too
unclear, please contact me via EasyPlex or BPROGA's TP5 message
section on CompuServe.
Rex Kerr 71550,3147
/\ RKCP /\
\/ RKCP \/